package com.mall.service.impl;

import com.mall.dao.ICarDao;
import com.mall.domain.Car;
import com.mall.domain.Order;
import com.mall.domain.Page;
import com.mall.service.ICarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CarServiceImpl implements ICarService {
    @Autowired
    private ICarDao carDao;

    @Override
    public Integer add(Car car) {
            return carDao.add(car);
    }

    @Override
    public List<Car> findAll(Integer members_id) {
        return carDao.findAll(members_id);
    }


    @Override
    public Integer findTotal(){
        return carDao.findTotal();
    }



    @Override
    public Integer del(Integer id) {
        return carDao.del(id);
    }

    @Override
    public Integer update(Car car) {
        return carDao.update(car);
    }
    @Override
    public Integer update1(Car car) {
        return carDao.update1(car);
    }


    @Override
    public List<Car> findAll1(Page page){
        //判断是否为模糊查询
        if(page.getQuery() == null){
            page.setQuery("%");
        } else {
            page.setQuery("%" + page.getQuery() + "%");
        }
        //设置分页查询开始值
        page.setNum((page.getNum() - 1) * page.getSize());
        return carDao.findAll1(page);
    }


}
